﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Forms;

namespace PI_CS_GUI
{
    class Program
    {
        [STAThread]
        static void Main()
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new PicsNCGUI());

           // PicsNetworkController _picsNC = new PicsNetworkController();

           // _picsNC.InitiateTopology();

            /*
            
            PicsNetworkController _picsNC= new PicsNetworkController();
            List<VirtualLink> _virtualLinks1 = new List<VirtualLink>();
            List<VirtualLink> _virtualLinks2 = new List<VirtualLink>();
            _virtualLinks1.Add(new VirtualLink("7", "8", new LinkParameters(1000, 70, 70)));
            _virtualLinks2.Add(new VirtualLink("7", "8", new LinkParameters(1000, 70, 70)));
            List<Route> VNRoutes = _picsNC.GetVNRequest(_virtualLinks1, "VNO1", new NetworkCoefficients(100, 1, 1), new LinkParameters(0, 500, 0));

            Console.WriteLine("VNO1:");
            Console.WriteLine();

            foreach (Route r in VNRoutes)
            {
                Console.WriteLine(r.Links[0].EndA + " to " + r.Links[r.Links.Count-1].EndB + " - " + r.ToString());
                Console.WriteLine();
            }

            List<Route> VNRoutes2 = _picsNC.GetVNRequest(_virtualLinks2, "VNO2", new NetworkCoefficients(100, 1, 1), new LinkParameters(0, 500, 0));

            Console.WriteLine("VNO2:");
            Console.WriteLine();

            foreach (Route r in VNRoutes2)
            {
                Console.WriteLine(r.Links[0].EndA + " to " + r.Links[r.Links.Count - 1].EndB + " - " + r.ToString());
                Console.WriteLine();
            }

            PicsServer server = new PicsServer();
            LoadConfiguration("config.xml");
   
            server.StartListening();



            while (true) { }
            /*
            Dictionary<SwitchingMatrix, Route> aa = net.UpdateRoutesFromNode(net.GetNode("1"));
            foreach (SwitchingMatrix key in aa.Keys)
            {
                Console.WriteLine(key.Id + "\t" + aa[key].ToString());
                Console.WriteLine();
            }
            while (true) { }
            */
            
        }

        /*
        
        
        public void CreateTopology()
        {
            AddNewNode("1", new MatrixParameters(10));
            AddNewNode("2", new MatrixParameters(20));
            AddNewNode("3", new MatrixParameters(10));
            AddNewNode("4", new MatrixParameters(10));
            AddNewNode("5", new MatrixParameters(20));
            AddNewNode("6", new MatrixParameters(60));
            AddNewNode("7", new MatrixParameters(30));
            AddNewNode("8", new MatrixParameters(30));

            AddNewLink("1", "4", new LinkParameters(2000, 60, 20));
            AddNewLink("4", "1", new LinkParameters(2000, 60, 20));
            AddNewLink("1", "7", new LinkParameters(3000, 20, 20));
            AddNewLink("7", "1", new LinkParameters(3000, 20, 20));
            AddNewLink("7", "4", new LinkParameters(3000, 20, 30));
            AddNewLink("4", "7", new LinkParameters(3000, 20, 30));
            AddNewLink("4", "2", new LinkParameters(1000, 10, 60));
            AddNewLink("2", "4", new LinkParameters(1000, 10, 60));
            AddNewLink("4", "6", new LinkParameters(3000, 10, 30));
            AddNewLink("6", "4", new LinkParameters(3000, 10, 30));
            AddNewLink("6", "8", new LinkParameters(1000, 20, 30));
            AddNewLink("8", "6", new LinkParameters(1000, 20, 30));
            AddNewLink("2", "8", new LinkParameters(3000, 10, 30));
            AddNewLink("8", "2", new LinkParameters(3000, 10, 30));
            AddNewLink("2", "5", new LinkParameters(2000, 50, 40));
            AddNewLink("5", "2", new LinkParameters(2000, 50, 40));
            AddNewLink("1", "5", new LinkParameters(2000, 30, 10));
            AddNewLink("5", "1", new LinkParameters(2000, 30, 10));
            AddNewLink("5", "3", new LinkParameters(1000, 20, 20));
            AddNewLink("3", "5", new LinkParameters(1000, 20, 20));
            AddNewLink("3", "8", new LinkParameters(3000, 10, 10));
            AddNewLink("8", "3", new LinkParameters(3000, 10, 10));
            AddNewLink("6", "7", new LinkParameters(2000, 30, 20));
            AddNewLink("7", "6", new LinkParameters(2000, 30, 20));
        }
         
        */
        
    }
}
